import pygame
from ui import msgbox
pressmouse = 0
keypress = 0
mousemode = 0
keydown = []


def reset():
    global pressmouse, keypress
    pressmouse = 0
    keypress = 0
    msgbox.pressmouse = 0


def update(event: pygame.event.Event):
    global pressmouse, keypress, mousemode, keydown
    if len(msgbox.msg_queue) == 0:
        if (event.type == pygame.MOUSEBUTTONUP):
            pressmouse = 1
            mousemode = 0
        elif (event.type == pygame.MOUSEBUTTONDOWN):
            mousemode = 1
        elif (event.type == pygame.KEYUP):
            keypress = event.key
            # if (event.key in keydown):
            #     del keydown[event.key]
        elif (event.type == pygame.KEYDOWN):
            keydown.append(event.key)
    else:
        if (event.type == pygame.MOUSEBUTTONUP):
            msgbox.pressmouse = 1
